module.exports = {
  pingDuoIfKdjTrans () {
    if (this.ifOnlyPingDuoByReason) {
      return
    }
    if (this.analysisInfo15m.kdjDiff < 0 && this.strategy === '1') {
      if (this.hasDuoPosition) {
        if (this.symbolAccount.incomeRate < 0) {
          // this.setPingDuo('pingDuoIfKdjTrans-1')
        }
      }
      if (
        this.analysisInfo15m.lastKdjUpRate >= 7.5 &&
        this.analysisInfo15m.kdjDownDays >= 2 &&
        (!this.isLongMarketGoodAnd15mUp() || this.analysisInfo15m.lastKdjUpRate >= 40) &&
        !this.marketFlagInfo.isMarketLittleGoodUp
      ) {
        // this.setPingDuo('pingDuoIfKdjTrans-2')
      }
      if (
        this.analysisInfo15m.lastKdjUpDays >= 18 &&
        this.analysisInfo15m.kdjDiff < 0
      ) {
        this.setPingDuo('pingDuoIfKdjTrans-3')
      }
      if (
        this.analysisInfo15m.kdjDiff < 0 &&
        // kdj是跌的结果你还涨了
        this.analysisInfo15m.kdjDownRate >= 15
      ) {
        this.setPingDuo('pingDuoIfKdjTrans-3-1')
      }
    }
    if (this.analysisInfo1h.kdjDiff < 0 && this.analysisInfo1h.isMacdDecline && this.strategy === '1') {
      if (this.analysisInfo15m.macd < 0 && this.analysisInfo15m.isMacdDecline) {
        if (this.analysisInfo15m.ema5A10A20Days >= 1 && this.analysisInfo15m.kdjDownDays >= 6) {
          // 挺好的
          this.setPingDuo('pingDuoIfKdjTrans-4')
        }
      }
    }
    // if (this.marketInfo.kdj15mBad && this.analysisInfo15m.macdDownDays === 1 && this.analysisInfo15m.isMacdDecline) {
    //   if (this.analysisInfo15m.kdjDownDays >= 2 && this.strategy === '1') {
    //     this.setPingDuo('pingDuoIfKdjTrans-5')
    //   }
    // }
    if (this.marketInfo.macd1hBad) {
      if (this.analysisInfo15m.kdjDiff < 0 && this.btbItem.strategy === '1' && this.strategy === '1') {
        // this.setPingDuo('pingDuoIfKdjTrans-6')
      }
    }
    if (
      (
        this.analysisInfo1h.netChangeRatioList[0] >= 20 &&
        this.analysisInfo1h.netChangeRatioList[1] >= 15
      ) ||
      (
        this.analysisInfo1h.netChangeRatioList[1] >= 15 &&
        this.analysisInfo1h.netChangeRatioList[0] >= 20
      )
    ) {
      if (this.tradeTime15mCycle === 4 && this.btbItem.strategy === '1') {
        this.setPingDuo('pingDuoIfKdjTrans-7')
      }
    }
  },
  pingDuoIfMarketInfo () {
    if (this.ifOnlyPingDuoByReason) {
      return
    }
    if (!this.marketInfo) {
      return
    }
    if (this.marketInfo) {
      if (!(this.marketInfo.onlyDuo || this.marketInfo.likeDuo)) {
        if (
          this.analysisInfo15m.macd < 0 &&
          this.analysisInfo15m.kdjDiff < 0
        ) {
          // this.setPingDuo('pingDuoIfMarketInfo-1',{
          //   canReverse: true
          // })
        }
      }
      if (this.marketFlagInfo.ifMarketNoDirection) {
        // 没有方向的状态
        if (this.hasDuoPosition && (this.strategy === '2' || this.btbItem.strategy === '2')) {
          if (
            this.analysisInfo15m.ema5 > this.analysisInfo15m.ema10 ||
            this.analysisInfo15m.macd > 0 ||
            this.analysisInfo15m.close > this.analysisInfo15m.ema10 ||
            this.analysisInfo15m.netChangeRatioUpDays >= 3 ||
            this.analysisInfo15m.close > this.analysisInfo15m.ema20
          ) {
            this.setPingDuo('pingDuoIfMarketInfo-1-1')
          }
        }
      }
      if (this.strategy === '2' && this.hasDuoPosition && !this.marketFlagInfo.ifMarket15mAllBad) {
        if (this.marketInfo.kdj4hBad && (this.marketInfo.kdj1hBad || this.marketInfo.macd1hBad)) {
          if (
            this.analysisInfo15m.ema5 > this.analysisInfo15m.ema10 &&
            (
              this.analysisInfo15m.close > this.analysisInfo15m.ema5 &&
              this.analysisInfo15m.close > this.analysisInfo15m.ema10 &&
              this.analysisInfo15m.close > this.analysisInfo15m.ema20
            )
          ) {
            this.setPingDuo('pingDuoIfMarketInfo-2')
          }
        }
        if (
          !this.marketFlagInfo.indexIfMarketUpTrend ||
          this.btbItem.keep_days >= 12
        ) {
          if (
            this.analysisInfo15m.ema5 < this.analysisInfo15m.ema10 &&
            this.analysisInfo15m.ema10 < this.analysisInfo15m.ema20 &&
            (
              this.analysisInfo15m.close > this.analysisInfo15m.ema5 &&
              this.analysisInfo15m.close > this.analysisInfo15m.ema10 &&
              this.analysisInfo15m.close > this.analysisInfo15m.ema20
            )
          ) {
            this.setPingDuo('pingDuoIfMarketInfo-3')
          }
          if (
            this.analysisInfo15m.ema5 > this.analysisInfo15m.ema20 &&
            (
              this.analysisInfo15m.close > this.analysisInfo15m.ema5 &&
              this.analysisInfo15m.close > this.analysisInfo15m.ema10 &&
              this.analysisInfo15m.close > this.analysisInfo15m.ema20
            )
          ) {
            this.setPingDuo('pingDuoIfMarketInfo-4')
          }
          if (
            this.analysisInfo15m.netChangeRatioUpDays >= 3 &&
            this.analysisInfo15m.close > this.analysisInfo15m.ema10
          ) {
            let pRate = (
              (this.analysisInfo15m.close > this.analysisInfo15m.ema20) ||
              (this.analysisInfo15m.ema5 > this.analysisInfo15m.ema10) ||
              (this.marketInfo.kdj15mGood && !this.marketInfo.macd15mBad)
            ) ? 1 : 0.5
            if (this.symbolAccount.incomeRate >= 0.8) {
              this.setPingDuo('pingDuoIfMarketInfo-5', {
                rate: 1 * pRate
              })
            } else {
              this.setPingDuo('pingDuoIfMarketInfo-5-1', {
                rate: 0.5 * pRate
              })
            }
          }
        }
        if (
          (this.marketInfo.macd4hBad && this.marketInfo.ema4hBad && this.marketInfo.kdj4hBad) &&
          !(this.marketInfo.macd1hGood || this.marketInfo.ema1hGood)
        ) {
          if (
            this.analysisInfo15m.netChangeRatioUpDays >= 3 &&
            this.analysisInfo15m.close > this.analysisInfo15m.ema20
          ) {
            this.setPingDuo('pingDuoIfMarketInfo-5-2')
          }
        }
      }
    }
    if (this.hasDuoPosition && this.symbolAccount.position > 0.6) {
      if (this.symbolAccount.incomeRate >= 0.4 && this.strategy === '1') {
        if (
          this.marketInfo.kdj15mBad &&
          !this.marketFlagInfo.ifMarket15mMacdEmaHasBad &&
          !this.isLongMarketGoodAnd15mUp() &&
          !this.marketFlagInfo.isMarketBigGoodUp
        ) {
          this.setPingDuo('pingDuoIfMarketInfo-6', {
            rate: 0.5
          })
        }
      }
    }
    let preCutRate = this.indexFlagInfo.isIndexInNewHighTrend ? 0.25 : 0.3
    if (this.marketFlagInfo.isMarketBigGoodUp) {
      preCutRate = 0.15
    }
    if (this.hasDuoPosition && this.symbolAccount.position > 0.2) {
      if (this.symbolAccount.incomeRate >= 0.4) {
        if (this.marketFlagInfo.ifMarket15mAllGood) {
          if (this.marketFlagInfo.isMarketFakeGoodUp) {
            preCutRate = 0.50
          }
          this.setPingDuo('pingDuoIfMarketInfo-7', {
            rate: preCutRate
          })
        }
      }
    }
    if (
      (this.marketInfo.kdj15mGood && !this.marketFlagInfo.ifMarket15mMacdEmaHasGood) &&
      (!this.marketInfo.kdj1hGood && !this.marketInfo.macd1hGood && this.marketInfo.ema1hGood) &&
      !this.marketFlagInfo.isMarketLittleGoodUp
    ) {
      // 挺好的
      this.setPingDuo('pingDuoIfMarketInfo-7-1', {
        rate: preCutRate
      })
      if (this.analysisInfo15m.macdUpDays >= 1 && this.analysisInfo15m.macdUpDays <= 2) {
        this.setPingDuo('pingDuoIfMarketInfo-7-1', {
          rate: this.indexFlagInfo.isIndexInNewHighTrend ? 0.4 : 0.5
        })
      }
    }
    if (
      (this.marketInfo.kdj4hBad && !this.marketInfo.macd4hGood) &&
      (this.marketInfo.macd1hBad)
    ) {
      if (this.hasDuoPosition && this.strategy === '2') {
        if ((this.marketInfo.kdj15mGood && !this.marketInfo.macd15mBad)) {
          this.setPingDuo('pingDuoIfMarketInfo-8-1', {
            rate: 0.5
          })
        }
      }
    }
    if (this.marketFlagInfo.ifMarket15mAllGood) {
      if (this.hasDuoPosition && this.symbolAccount.incomeRate < -1 && this.btbItem.keep_days > 2) {
        this.setPingDuo('pingDuoIfMarketInfo-9', {
          rate: 0.5
        })
      }
    }
    if (
      (this.marketFlagInfo.ifMarket1dMacdEmaAllBad && this.marketFlagInfo.ifMarket4hMacdEmaAllBad) &&
      (this.marketInfo.ema1hBad && this.marketInfo.kdj1hBad) &&
      (this.marketInfo.ema15mBad && !this.marketInfo.macd1hBad && !this.marketFlagInfo.ifMarket15mHasGood)
    ) {
      if (this.hasDuoPosition && this.strategy === '2') {
        this.setPingDuo('pingDuoIfMarketInfo-10-1', {
          rate: 0.5
        })
      }
    }
    if (
      (this.marketInfo.ema15mGood && this.marketInfo.macd15mGood) &&
      (this.hasDuoPosition && this.btbItem.strategy === '2') &&
      this.btbItem.keep_days >= 4
    ) {
      this.setPingDuo('pingDuoIfMarketInfo-10-2', {
        rate: 0.5
      })
    }
    if (this.hasDuoPosition && this.btbItem.strategy === '2' && this.btbItem.keep_days >= 8) {
      if (this.marketInfo.kdj4hBad && this.marketInfo.kdj1hBad && this.marketInfo.ema1hBad) {
        if (
          this.analysisInfo15m.macdDownDays >= 1 &&
          (this.analysisInfo15m.macdDownDays + this.analysisInfo15m.lastMacdUpDays) < this.btbItem.keep_days &&
          this.analysisInfo15m.isKong
        ) {
          this.setPingDuo('pingDuoIfMarketInfo-10-3', {
            rate: this.analysisInfo15m.macdDownDays >= 2 ? 1 : 0.5
          })
        }
      }
    }
  },
  pingDuoIfMacdUpManyDaysDown () {
    if (this.ifOnlyPingDuoByReason) {
      return
    }
    // 一波上涨（macd20以上，5和10大20大于20以上），macd下了，kdj下面6天了，那就得卖出
    if (
      this.analysisInfo15m.macd < 0 &&
      (
        this.analysisInfo15m.ema5 < this.analysisInfo15m.ema20 ||
        this.analysisInfo15m.ema10 < this.analysisInfo15m.ema20
      )
    ) {
      if (this.strategy === '2' && this.symbolAccount.incomeRate >= 1) {
        // 逆向
        if (this.analysisInfo15m.ema5B10B20Days >= 1) {
          this.setPingDuo('pingDuoIfMacdUpManyDaysDown-10', {
            canReverse: true
          })
        }
      } else {
        this.setPingDuo('pingDuoIfMacdUpManyDaysDown-10-1', {
          canReverse: true
        })
      }
    }
    if (
      this.analysisInfo15m.lastMacdUpDays >= 20 &&
      (
        this.analysisInfo15m.ema5W10A20Days >= 20 ||
        this.analysisInfo15m.lastEma5W10A20Days >= 20
      )
    ) {
      if (
        this.analysisInfo15m.macdDownDays >= 4 &&
        this.analysisInfo15m.kdjDownDays >= 6 &&
        !(this.analysisInfo15m.ema5W10A20Days >= 80)
      ) {
        if (this.strategy === '2') {
          if (!(this.marketInfo.macd1hBad && this.marketInfo.ema1hBad && this.marketInfo.macd4hBad && this.marketInfo.ema4hBad)) {
            // 逆向
            if (this.analysisInfo15m.ema5B10B20Days >= 1) {
              this.setPingDuo('pingDuoIfMacdUpManyDaysDown-1', {
                canReverse: true
              })
            }
          }
        } else {
          this.setPingDuo('pingDuoIfMacdUpManyDaysDown-1-1', {
            canReverse: true
          })
        }
      }
      if (
        this.analysisInfo15m.macdDownDays >= 6 &&
        this.analysisInfo15m.kdjDiff < 0 &&
        !(this.analysisInfo15m.ema5W10A20Days >= 80)
      ) {
        if (this.strategy === '2' && this.symbolAccount.incomeRate >= 1) {
          // 逆向
          if (this.analysisInfo15m.ema5B10B20Days >= 1) {
            this.setPingDuo('pingDuoIfMacdUpManyDaysDown-1-2', {
              canReverse: true
            })
          }
        } else {
          this.setPingDuo('pingDuoIfMacdUpManyDaysDown-1-3', {
            canReverse: true
          })
        }
      }
    }
    if (
      this.analysisInfo1h.lastMacdUpDays >= 20 &&
      (
        this.analysisInfo1h.ema5W10A20Days >= 20 ||
        this.analysisInfo1h.lastEma5W10A20Days >= 20
      )
    ) {
      if (
        this.analysisInfo1h.macdDownDays >= 4 &&
        this.analysisInfo1h.kdjDownDays >= 6
      ) {
        this.setPingDuo('pingDuoIfMacdUpManyDaysDown-2', {
          canReverse: true
        })
      }
      if (
        this.analysisInfo1h.macdDownDays >= 6 &&
        this.analysisInfo1h.kdjDiff < 0
      ) {
        this.setPingDuo('pingDuoIfMacdUpManyDaysDown-2-2', {
          canReverse: true
        })
      }
    }
  },
  pingDuoIfNowTopHigh () {
    if (this.ifOnlyPingDuoByReason) {
      return
    }
    let rate = 12
    if (this.marketFlagInfo.isMarketLittleGoodUp) {
      rate = 17
    }
    if (this.analysisInfo15m.netChangeRatio > rate) {
      this.setNoSell()
      this.setPingDuo('pingDuoIfNowTopHigh-1')
    }
  },
  pingDuoIfNowBigDown () {
    let avRate = this.analysisInfo15m.before10DaysAvMaxWave
    if (avRate < 0.3) {
      avRate = 0.3
    }
    // 15一波上涨后，突然一个下跌，波动是之前10倍，然后macd下大于等于3天，然后51020转下第一天，
    if (
      this.analysisInfo15m.netChangeRatio < 0 &&
      this.analysisInfo15m.highLowRate / avRate > 10 &&
      this.analysisInfo15m.macdDownDays >= 3 &&
      this.analysisInfo15m.ema5B10B20Days >= 1 &&
      this.analysisInfo15m.ema5B10B20Days <= 3 &&
      this.analysisInfo15m.lastMacdUpDays >= 20 &&
      this.analysisInfo15m.lastEma5W10A20Days >= 20
    ) {
      this.setNoSell()
      this.setPingDuo('pingDuoIfNowBigDown-1')
    }
  },
  pingDuoByConfig () {
    // 平仓
    if (this.btbItem.ping_next_k && this.hasDuoPosition) {
      this.setPingDuo('pingDuoByConfig-1')
    }
    if (this.btbItem.ping_next_1hk && this.hasDuoPosition && this.tradeTime15mCycle === 4) {
      this.setPingDuo('pingDuoByConfig-2')
    }
  },
  pingDuoReversePosition () {
    if (this.ifOnlyPingDuoByReason) {
      return
    }
    if (this.strategy === '1' && this.btbItem.strategy === '2' && this.marketFlagInfo.isMarketLittleBadDown) {
      if (this.hasDuoPosition && this.symbolAccount.incomeRate <= -2) {
        this.setPingDuo('pingDuoReversePosition-1')
        this.manual = 1
      }
    }
  },
  pingDuoIfProfitReduce () {
    if (this.ifOnlyPingDuoByReason) {
      return
    }
    if (this.buy) {
      return
    }
    const max_income_rate = this.btbItem.max_income_rate || 0
    if (this.hasDuoPosition && max_income_rate >= 6) {
      if (this.symbolAccount.incomeRate < max_income_rate * 0.66666) {
        // this.setPingDuo('pingDuoIfProfitReduce-1')
      }
    }
  },
  // 交易低的平仓
  pingDuoIfVolumeLow () {
    if (this.marketInfo && this.marketInfo.quoteVolumeSum <= 120) {
      if (this.hasDuoPosition && this.btbItem.strategy === '1') {
        if (this.analysisInfo15m.macd < 0) {
          this.setPingDuo('pingDuoIfVolumeLow-1')
        }
      }
    }
  },
  pingDuoIfStopLoss () {
    let baseLossRate = -12
    if (this.hasDuoPosition) {
      if (this.btbItem.strategy === '2') {
        if (
          this.symbolAccount.incomeRate <= baseLossRate &&
          !this.marketFlagInfo.ifMarket15mAllBad &&
          this.analysisInfo15m.netChangeRatio > -5
        ) {
          this.setPingDuo('pingDuoIfStopLoss-1')
          this.manual = 1
        }
        // if (this.symbolAccount.incomeRate <= -2 && this.btbItem.keep_days >= 6) {
        //   this.setPingDuo('pingDuoIfStopLoss-2')
        // }
        if (this.symbolAccount.incomeRate < 0 && this.btbItem.keep_days > 25) {
          if (
            this.analysisInfo15m.ema5 > this.analysisInfo15m.ema10 ||
            this.analysisInfo15m.close > this.analysisInfo15m.ema20 ||
            this.analysisInfo15m.macd > 0 ||
            this.analysisInfo15m.close > this.analysisInfo15m.ema10 ||
            this.analysisInfo15m.netChangeRatioUpDays >= 3
          ) {
            this.setPingDuo('pingDuoIfStopLoss-2-1')
          }
        }
        if (this.btbItem.keep_days >= 17 && (this.symbolAccount.incomeRate < 0 || !this.buy)) {
          if (this.analysisInfo15m.ema5 > this.analysisInfo15m.ema10) {
            this.setPingDuo('pingDuoIfStopLoss-2-2')
          }
          if (
            this.analysisInfo15m.macd > 0 &&
            this.analysisInfo15m.close > this.analysisInfo15m.ema10 &&
            this.analysisInfo15m.netChangeRatioUpDays >= 3
          ) {
            this.setPingDuo('pingDuoIfStopLoss-2-3')
          }
          if (this.analysisInfo15m.close > this.analysisInfo15m.ema20) {
            this.setPingDuo('pingDuoIfStopLoss-2-4')
          }
        }
        if (this.symbolAccount.incomeRate < 0 && this.btbItem.keep_days > 32) {
          this.setPingDuo('pingDuoIfStopLoss-2-5')
        }
        if (
          this.symbolAccount.incomeRate <= -2 &&
          (this.marketInfo && (this.marketInfo.crash15mKdjGood)) &&
          this.analysisInfo15m.kdjDiff < 0
        ) {
          // 错了马上止损确实能保命
          // this.setPingDuo('pingDuoIfStopLoss-2-2')
        }
        // 新高的，逆向仓位，亏损超过1的本金，就开始不断减仓
        if (this.symbolAccount.incomeAssetRate <= -1.5 && this.symbolAccount.incomeRate <= -8 && this.hasDuoPosition) {
          if (this.indexFlagInfo.isIndexCloseNowNewLow && this.marketInfo.newLowRate < 0.1) {
            // 同时新低的东西并不多
            this.setPingDuo('pingDuoIfStopLoss-2-6', {
              rate: 0.2
            })
          }
        }
        // 逆向做空的，如果加过仓，然后变亏损了，然后这个k又是涨的那就砍掉一半的仓位，不然就是暴涨，大金额的亏损都是这个原因
        // 是不是可以干脆做正向
        if (
          this.btbItem.add_times >= 1 &&
          this.symbolAccount.incomeRate < 0 &&
          this.btbItem.keep_days >= 4 &&
          this.analysisInfo15m.netChangeRatio < 0 &&
          this.analysisInfo15m.netChangeRatio > -7.5 &&
          this.analysisInfo15m.kdjDiff < 0 &&
          this.analysisInfo15m.isKdjDecline
        ) {
          if (
            !(this.marketInfo.macd15mBad && this.marketInfo.ema15mBad) &&
            this.marketFlagInfo.lastMarket15mAllBadIndex >= 6
          ) {
            this.setPingDuo('pingDuoIfStopLoss-2-7')
          }
        }
      } else {
        // 出货K要平仓
        if (
          this.analysisInfo15m.highOpenRate > 7.5 &&
          this.analysisInfo15m.netChangeRatio < -1
        ) {
          // 涨了很多结果还给砸绿了
          this.setPingDuo('pingDuoIfStopLoss-3-1')
          this.manual = 1
        }
        if (this.buy) {
          return
        }
        // 做多才有
        if (
          (
            this.analysisInfo15m.ema5A10A20Days >= 1 ||
            (this.analysisInfo15m.ema5W10A20Days >= 1 && this.analysisInfo15m.ema5B10Days === 1)
          ) &&
          this.analysisInfo15m.netChangeRatio < -4 &&
          this.marketFlagInfo.indexIfMarketUpTrend
          // 一个出货急跌
        ) {
          return
        }
        if (
          this.symbolAccount.incomeRate <= baseLossRate &&
          !this.marketFlagInfo.ifMarket15mAllBad &&
          this.analysisInfo15m.netChangeRatio > -5
        ) {
          this.setPingDuo('pingDuoIfStopLoss-3')
          this.manual = 1
        }
        // if (this.symbolAccount.incomeRate <= -2 && this.btbItem.keep_days > 8) {
        //   this.setPingDuo('pingDuoIfStopLoss-4')
        // }
        if (this.symbolAccount.incomeRate < 0 && this.btbItem.keep_days > 25) {
          this.setPingDuo('pingDuoIfStopLoss-4-1')
        }
        if (
          this.symbolAccount.incomeRate < 0 &&
          (this.marketInfo && (this.marketInfo.attack15mKdjDown || this.marketInfo.likeDuoKdjDown)) &&
          this.analysisInfo15m.kdjDiff < 0 &&
          !this.marketFlagInfo.indexIfMarketUpTrend
        ) {
          // 错了马上止损确实能保命
          if ((
            this.analysisInfo15m.ema5 > this.analysisInfo15m.ema20 ||
            this.analysisInfo15m.ema5B20Days <= 2
          ) && (this.marketInfo.ema1hGood && this.marketInfo.ema4hGood)) {
            if (this.analysisInfo15m.netChangeRatio > 0) {
              this.setPingDuo('pingDuoIfStopLoss-4-3-1')
            }
          } else {
            this.setPingDuo('pingDuoIfStopLoss-4-3-1')
          }
        }
        if (
          this.marketFlagInfo.indexIfMarket15mDownTrend &&
          !this.marketFlagInfo.indexIfMarketUpTrend &&
          this.hasDuoPosition
        ) {
          // 效果不好
          // this.setPingDuo('pingDuoIfStopLoss-4-4')
        }
        if (
          this.marketFlagInfo.indexIfMarketUpTrend &&
          !this.marketInfo.kdj15mGood
        ) {
          if ((
            (this.marketInfo.macd15mBad && !this.marketInfo.ema15mGood) ||
            (this.marketInfo.ema15mBad && !this.marketInfo.macd15mGood)
          )) {
            if (
              this.analysisInfo15m.kdjDiff < 0 &&
              !(this.marketInfo.macd1hGood && this.marketInfo.ema1hGood)
            ) {
              this.setPingDuo('pingDuoIfStopLoss-4-5')
            }
          }
          if (this.marketInfo.macd15mBad || this.marketInfo.ema15mBad) {
            if (this.analysisInfo15m.netChangeRatio > 0 && this.analysisInfo15m.kdjDiff > 0 && this.analysisInfo15m.macd < 0) {
              this.setPingDuo('pingDuoIfStopLoss-4-6')
            }
          }
        }
      }
    }
  },
  pingDuoByReason () {
    if (!this.btbItem.buy_sell_reason) {
      return
    }
    if (
      this.btbItem.buy_sell_reason === 'buyIfOnlyPingByReason-1' ||
      this.btbItem.buy_sell_reason === 'buyIfOnlyPingByReason-2' ||
      this.btbItem.buy_sell_reason === 'buyIfOnlyPingByReason-3'
    ) {
      if (
        this.analysisInfo15m.kdjDiff > 0 ||
        this.analysisInfo15m.netChangeRatioUpDays >= 3 ||
        (this.analysisInfo15m.high > this.analysisInfo15m.ema5)
      ) {
        this.setPingDuo('pingDuoByReason-1')
        // 再做一笔卖出
        // this.setSell('sell-pingDuoByReason-1', {
        // })
      }
    }
    if (['buyIfOnlyPingByReason-5'].indexOf(this.btbItem.buy_sell_reason) !== -1) {
      if (
        this.analysisInfo15m.kdjDiff > 0 ||
        this.analysisInfo15m.netChangeRatioUpDays >= 3 ||
        (this.analysisInfo15m.high > this.analysisInfo15m.ema10) ||
        (this.analysisInfo15m.close > this.analysisInfo15m.ema5)
      ) {
        this.setPingDuo('pingDuoByReason-1-1')
      }
    }
    if (this.btbItem.buy_sell_reason === 'buyIfStepBack-1') {
      // 回踩的
      if (this.analysisInfo15m.ema5 > this.analysisInfo15m.ema10) {
        if (this.marketInfo && this.marketInfo.kdj15mGood && !this.marketInfo.macd15mBad) {
          this.setPingDuo('pingDuoByReason-2')
        }
      }
      if (this.symbolAccount.incomeRate <= -4) {
        this.setPingDuo('pingDuoByReason-2-1')
      }
      if (this.analysisInfo15m.ema5A10A20Days >= 1 && this.analysisInfo15m.isKdjDecline) {
        this.setPingDuo('pingDuoByReason-2-2')
      }
      if (this.marketInfo.ema4hGood && !this.marketInfo.macd4hGood) {
        if (this.analysisInfo15m.macdUpDays === 1) {
          if (
            this.analysisInfo15m.close > this.analysisInfo15m.ema20 &&
            this.analysisInfo15m.close > this.analysisInfo15m.ema10 &&
            !this.marketInfo.kdj15mBad
          ) {
            this.setPingDuo('pingDuoByReason-2-3')
          }
        }
      }
      if (this.analysisInfo15m.ema5B10Days === 1) {
        this.setPingDuo('pingDuoByReason-2-4')
      }
    }
    if (this.btbItem.buy_sell_reason === 'buyIfOnlyPingByReason-4') {
      if (this.analysisInfo15m.macdUpDays >= 1 && this.analysisInfo15m.ema5A10A20Days >= 1) {
        this.setPingDuo('pingDuoByReason-3-1')
      }
    }
    if (this.btbItem.buy_sell_reason === 'buyIfStepBack-2') {
      if (this.analysisInfo1h.macd < 0) {
        this.setPingDuo('pingDuoByReason-4-1')
      }
      if (this.analysisInfo1h.kdjDownDays >= 5) {
        this.setPingDuo('pingDuoByReason-4-2')
      }
    }
    if (this.isInBuySellReason([
      'buyIfOnlyPingByReason-0001'
    ])) {
      if (this.analysisInfo1h.ema5 > this.analysisInfo1h.ema20 && this.tradeTime15mCycle === 4 && this.analysisInfo1h.isKdjDecline) {
        this.setPingDuo('pingDuoByReason-5-0')
      }
    }
    if (this.isInBuySellReason([
      'buyIfOnlyPingByReason-mbd-0001',
      'buyIfOnlyPingByReason-mbd-0002',
      'buyIfOnlyPingByReason-mbd-0003'
    ])) {
      if (this.analysisInfo15m.kdjDiff > 0) {
        this.setPingDuo('pingDuoByReason-6-0')
      }
      if (this.analysisInfo15m.netChangeRatioUpDays >= 2) {
        this.setPingDuo('pingDuoByReason-6-1')
      }
    }
  },
  pingDuoByCanOpenMany () {
    if (!this.marketInfo) {
      return
    }
    if (this.ifOnlyPingKongByReason || this.ifOnlyPingDuoByReason) {
      return
    }
    const canOpenList = this.marketInfo.canOpenList || []
    // 平衡仓位，杜绝很垃圾然后还占用很大仓位的情况
    // canOpenList要多，不然你仓位平掉，后续没有买入也尴尬
    if (this.btbItem.strategy === '2' && this.hasDuoPosition && canOpenList.length > 15) {
      // canopen多说明支持的买入也多
      if (this.futuresAccount.btbCount > 25) {
        // 1.5有点多了
        if (this.symbolAccount.rawPosition >= 1.5) {
          this.setPingDuo('pingDuoByCanOpenMany-1-1', {
            rate: 1 - (1 / this.symbolAccount.rawPosition)
          })
        }
      }
    }
  },
  pingDuoIfProfitMany () {
    if (this.ifOnlyPingDuoByReason) {
      return
    }
    if (this.hasDuoPosition) {
      if (this.is4hLastTime && this.symbolAccount.incomeRate >= 8) {
        this.setPingDuo('pingDuoIfKeepProfit-1-1', {
          rate: 0.5
        })
      }
    }
  },
  // 情绪激动，平掉一部分
  pingDuoIfKeepProfit () {
  },
  pingDuoIfMarketOneDayUpMany () {
    if (this.isDayChangeTime) {
      if (
        this.marketInfo.max50AvRate >= 20 &&
        !(this.marketFlagInfo.ifMarket4hMacdEmaAllGood && this.marketFlagInfo.ifMarket1hMacdEmaAllGood && this.marketFlagInfo.ifMarket15mMacdEmaHasGood)
      ) {
        this.setPingDuo('pingDuoIfMarketOneDayUpMany-1-1')
      }
    }
  },
  pingDuoForce () {
    if (this.hasDuoPosition) {
      if (this.symbolAccount.incomeRate < -16 && (
        this.analysisInfo15m.macd < 0 &&
        (this.analysisInfo15m.ema5 < this.analysisInfo15m.ema20)
      )) {
        this.setPingDuo('pingDuoForce-1-1')
      }
    }
  }
}
